<template>
	<view class="content">
		<mescroll-uni ref="mescrollRef" @init="mescrollInit" @up="upCallback" :up="upOption" :down="{use: false}">
		<view class="section-1">
			<view class="section-body">
				<view class="item" v-for="item in board" :key="item.name">
					<view class="shape" v-if="item.right"></view>
					<view class="shape2" v-if="item.bottom"></view>
					<view class="top">{{item.name}}</view>
					<view class="bottom">{{item.count}}<text>{{item.unit}}</text></view>
				</view>
			</view>
		</view>
		<view class="section-0">
			<view class="section-body">
				<view class="form">
					<view class="form-item">
						<view class="label">项目名称</view>
						<view class="shape"></view>
						<view class="input">
							<u--input placeholderClass="input-placeholder" class="input-body" placeholder="项目名称"
								v-model="form.project_name"></u--input>
						</view>
					</view>
					<view class="actions">
						<view class="action" @click="handleResetForm()">
							<text>重</text>
							<text>置</text>
						</view>
						<view class="action search" @click="handleSearch()">
							<text>查</text>
							<text>询</text>
						</view>
					</view>
				</view>
				<view class="list">
					<view class="item" v-for="item in list" :key="item.id">
						<view class="left">
							<view class="name">
								{{item.title}}
							</view>
							<view class="info">
								<text>分享人  {{item.title1}}</text>
							</view>
						</view>
						<view class="action" @click="handleDownload(item.filePath)">
							<!-- <view class="iconfont icon-xiazai"></view> -->
<!-- 							<view class="down-count">
								{{item.title1}}次
							</view> -->
							<view class="imgs">
								<view class="img">
									<text class="label"
										<text>{{item.title2}}</text>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		</mescroll-uni>
	</view>
</template>

<script>
	import { checkListApi } from '@/api/statistics.js';
	export default {
		data() {
			return {
				form: {
					project_name: ''
				},
				board: [
					{ name: '待报计划个数', count: 0, right: true, bottom: true, type: 'risk_num' },
					{ name: '计划总数', count: 0, right: true,  bottom: true, type: 'risk_num_2' },
					{ name: '合同总数', count: 0, bottom: true, unit:'', type: 'risk_num_3' },
					{ name: 'Ⅰ类问题总数', count: 0, right: true, type: 'work_count' },
					{ name: 'Ⅱ类问题总数', count: 0, right: true, type: 'risk_ratio_2' },
					{ name: 'Ⅲ类问题总数', count: 0, type: 'risk_ratio_3' },
				],
				list: [
					{
						title:'测试测试测试测试测试测试',
						title1:'XXX招标',
						title2:'待报计划'
					},
					{
						title:'测试测试测试测试测试测试',
						title1:'XXX招标',
						title2:'待报计划'
					},
					{
						title:'测试测试测试测试测试测试',
						title1:'XXX招标',
						title2:'待报计划'
					},
					{
						title:'测试测试测试测试测试测试',
						title1:'XXX招标',
						title2:'待报计划'
					},
				],
				expandList: [],
				mescroll: null, // mescroll实例对象 (此行可删,mixins已默认)
				upOption: {
					textNoMore: '-- 没有更多了 --'
				},
				pageSize: 20,
			}
		},
		methods: {
			go(item) {
				let params = { id: item.id, project_name: item.project_name };
				uni.navigateTo({
					url: '/pages/statistics/safety/problem/info/index?params=' + JSON.stringify(params)
				})
			},
			handleResetForm(){
				for (let key in this.form) {
					this.form[key] = '';
				}
				this.mescroll.resetUpScroll();
this.mescroll.scrollTo(0,0);
			},
			handleSearch(){
				this.mescroll.resetUpScroll();
this.mescroll.scrollTo(0,0);
			},
			expandChange(id) {
				const idx = this.expandList.indexOf(id);
				if (idx !== -1) {
					this.expandList.splice(idx, 1);
				} else {
					this.expandList.push(id);
				}
			},
			/*mescroll组件初始化的回调,可获取到mescroll对象 (此处可删,mixins已默认)*/
			mescrollInit(mescroll) {
				this.mescroll = mescroll;
			},
			/*上拉加载的回调*/
			async upCallback(page) {
				const {data} =  await checkListApi({
					...this.form,
					page: page.num,
					pageSize: this.pageSize
				});
				
				// if (data.code === 1 || data.code === 200) {
				// 	const list = [];
				// 	this.board[0].count = data.data.tongJi.total;
				// 	this.board[1].count = data.data.tongJi.unchanged_total;
				// 	this.board[2].count = data.data.tongJi.fk_money;
				// 	this.board[3].count = data.data.tongJi.one_total;
				// 	this.board[4].count = data.data.tongJi.two_total;
				// 	this.board[5].count = data.data.tongJi.three_total;
				// 	for (let key in data.data.list.data) {
				// 		list.push({...data.data.list.data[key]})
				// 	}
				// 	// 接口返回的当前页数据列表 (数组)
				// 	let curPageData = list; 
				// 	// 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
				// 	let curPageLen = curPageData.length; 
				// 	// 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
				// 	let totalPage = data.data.list.last_page; 
				// 	//设置列表数据
				// 	if(page.num == 1) this.list = []; //如果是第一页需手动置空列表
				// 	this.list = this.list.concat(curPageData); //追加新数据
				// 	// 请求成功,隐藏加载状态
				// 	this.mescroll.endByPage(curPageLen, totalPage); 
				// 	setTimeout(()=>{
				// 		this.mescroll.endSuccess(curPageLen);
				// 	},20);
				// } else{
				// 	//  请求失败,隐藏加载状态
				// 	this.mescroll.endErr()
				// }
			},
		},
	}
</script>

<style lang="scss" scoped>
	.section-1{
		width: 100%;
		background-color: #2e5efe;
		.section-body{
			width: 100%;
			height: 215rpx;
			padding-left: 40rpx;
			padding-right: 40rpx;
			padding-bottom: 50rpx;
			padding-top: 20rpx;
			background-color: #1534ce;
			background-size: cover;
			background-repeat: no-repeat;
			border-top-left-radius: 50rpx;
			border-top-right-radius: 50rpx;
			overflow: hidden;
			box-sizing: border-box;
			.item{
				width: 33.33%;
				float: left;
				display: flex;
				flex-wrap: wrap;
				align-content: space-between;
				height: 100rpx;
				position: relative;
				padding-top: 20rpx;
				padding-bottom: 20rpx;
				.shape{
					width: 4rpx;
					height: 84rpx;
					background-image: linear-gradient(rgba(#3658f2, 0.3) 0%, #3658f2 30%, #3658f2 70%, rgba(#3658f2, 0.3) 100%,);
					position: absolute;
					right: 0;
					top: 28rpx;
				}
				.shape2{
					height: 4rpx;
					width: 172rpx;
					background-image: linear-gradient(90deg, rgba(#3658f2, 0.3) 0%, #3658f2 30%, #3658f2 70%, rgba(#3658f2, 0.3) 100%,);
					position: absolute;					
					left: 0;
					right: 0;
					margin: 0 auto;
					bottom: -2rpx;
				}
				.top{
					width: 100%;
					text-align: center;
					font-size: 16rpx;
					font-weight: normal;
					font-stretch: normal;
					letter-spacing: 0rpx;
					color: #95c4fa;
				}
				.bottom{
					width: 100%;
					text-align: center;
					font-size: 45rpx;
					font-weight: bold;
					font-stretch: normal;
					letter-spacing: 0rpx;
					color: #ffde00;
					word-break: keep-all;
					text{
						font-size: 22rpx;
					}
				}
			}
		}
	}
	.section-0 {
		width: 100%;
		background: #2e5efe;
		position: relative;
		top: -50rpx;
		z-index: 10;
		border-top-left-radius: 50rpx;
		background-color: #fff;
		border-top-right-radius: 50rpx;
		.section-body {
			width: 100%;
			height: 100%;
			border-top-left-radius: 50rpx;
			border-top-right-radius: 50rpx;
			background-color: #fff;
			overflow: hidden;
			.tab{
					width: 100%;
					height: 80rpx;
					@include clear();
					background-color: #1534ce;
					.item{
						width: 33.33%;
						float: left;
						height: 80rpx;
						background-color: #1534ce;
						position: relative;
						.label{
							height: 80rpx;
							line-height: 80rpx;
							position: relative;
							z-index: 10;
							box-sizing: border-box;
							text-align: center;
							width: 100%;
							font-size: 26rpx;
							font-weight: normal;
							font-stretch: normal;
							letter-spacing: 0rpx;
							color: #ffffff;
						}
						.shape{
							z-index: 1;
							width: 50rpx;
							height: 50rpx;
							position: absolute;
							bottom: 0;
							left: -50rpx;
							background: #000;
							display: none;
							background-color: #fff;
							overflow: hidden;
							.shape-body{
								width: 50rpx;
								height: 50rpx;
								background-color: #1534ce;
								border-bottom-right-radius: 40rpx;
							}
						}
						.shape-mirrow{
							z-index: 1;
							left: 0;
							display: none;
							.shape-body{
								border-bottom-right-radius: 0rpx;
								border-bottom-left-radius: 40rpx;
							}
						}
					}
					.item__active{
						border-top-left-radius: 40rpx;
						border-top-right-radius: 40rpx;
						background-color: #fff;
						.label{
							color: #46464a;
						}
						.shape{
							display: block;
						}
						.shape-mirrow{
							display: none;
						}
					}
					.item__active_next{
						border-bottom-right-radius: 50rpx;
						.shape{
							display: none;
						}
						.shape-mirrow{
							display: block;
						}
					}
				
			}
			.list{
				width: 670rpx;
				box-sizing: border-box;
				margin-left: 40rpx;
				border-top: 2rpx solid #d8e4f2;
				.item{
					box-sizing: border-box;
					width: 100%;
					padding: 20rpx 40rpx 15rpx 40rpx;
					border-bottom: solid 2rpx #f2f2f0;
					@include clear();
					.left{
						float: left;
						width: 520rpx;
						.info{
							width: 100%;
							float: left;
							height: 24rpx;
							line-height: 24prx;
							font-size: 16rpx;
							color: #7f98ae;
							text{
								margin-right: 30rpx;
								&:last-child{
									margin-right: 0;
								}
							}
						}
						.name{
							width: 520rpx;
							height: 40rpx;
							font-size: 26rpx;
							font-weight: normal;
							font-stretch: normal;
							line-height: 40rpx;
							letter-spacing: 2rpx;
							color: #3b3c40;
							text-overflow: ellipsis;
							overflow: hidden;
							white-space: nowrap;
							float: left;
						}
					}
					.action{
						float: right;
						width: 70rpx;
						text-align: right;
						color: #3b3c40;
						.iconfont{
							display: inline-block;
							height: 40rpx;
							line-height: 40rpx;
							font-size: 32rpx;
							transition: 0.2s ease;
						}
						.down-count{
							width: 100%;
							height: 24rpx;
							line-height: 24prx;
							font-size: 16rpx;
							color: #7f98ae;
							white-space: nowrap;
						}					
					}
				}
			}

			.actions {
				width: 100%;
				height: 50rpx;
				margin-top: 29rpx;
				padding-bottom: 40rpx;
				display: flex;
				justify-content: space-between;

				.action {
					width: 288rpx;
					height: 48rpx;
					background-color: #395cf5;
					border-radius: 20rpx;
					text-align: center;
					line-height: 48rpx;
					font-size: 26rpx;
					font-weight: normal;
					font-stretch: normal;
					line-height: 48rpx;
					color: #ffffff;

					text {
						&:first-child {
							margin-right: 20rpx;
						}
					}
				}

				.search {
					background-color: #1534ce;
				}
			}

			.form {
				width: 100%;
				padding: 0 75rpx;
				padding-top: 40rpx;
				box-sizing: border-box;

				.form-item {
					width: 600rpx;
					height: 48rpx;
					border-radius: 20rpx;
					border: solid 2rpx #1534ce;
					margin: 0 auto;
					margin-bottom: 25rpx;

					&:last-child {
						margin-bottom: 34rpx;
					}

					@include clear();

					.label {
						float: left;
						width: 134rpx;
						height: 48rpx;
						text-align: center;
						line-height: 44rpx;
						font-size: 26rpx;
						font-weight: normal;
						font-stretch: normal;
						letter-spacing: 0rpx;
						color: #1534ce;
					}

					.shape {
						width: 3rpx;
						height: 32rpx;
						background-color: #7f98ae;
						float: left;
						margin-top: 8rpx;
					}

					.input {
						float: left;
						width: calc(100% - 134rpx - 3rpx);

						.input-body {
							box-sizing: border-box;
							width: 100%;
							height: 44rpx;
							padding: 0 !important;
							border: none;
							padding-left: 30rpx !important;
							padding-right: 30rpx !important;
							font-size: 26rpx;
							font-weight: normal;
							font-stretch: normal;
							letter-spacing: 0rpx;
							color: rgba(0, 0, 0, 0.7);
						}

						.input-placeholder {
							font-size: 26rpx;
							font-weight: normal;
							font-stretch: normal;
							letter-spacing: 0rpx;
							color: rgba(0, 0, 0, 0.5);
						}
					}
				}
			}

			.total {
				box-sizing: border-box;
				padding: 0 70rpx;
				height: 80rpx;
				line-height: 70rpx;
				font-size: 22rpx;
				font-weight: normal;
				font-stretch: normal;
				line-height: 80rpx;
				letter-spacing: 0rpx;
				color: #3b3c40;
			}

			.charts {
				width: 100%;
				box-sizing: border-box;
				height: 315rpx;
				padding: 0 70rpx;
				padding-left: calc(70rpx - 15px);
				margin-bottom: 30rpx;
				#echarts {
					width: 100%;
					height: 100%;
				}
			}

			.top-tab {
				width: 670rpx;
				margin-left: 40rpx;
				height: 52rpx;
				line-height: 52rpx;
				display: flex;
				justify-content: space-between;
				box-sizing: border-box;
				padding: 0 30rpx;
				margin-top: 15rpx;
				border-bottom: solid 3rpx #f2f2f0;

				.item {
					font-size: 26rpx;
					font-weight: normal;
					font-stretch: normal;
					line-height: 50rpx;
					letter-spacing: 0rpx;
					color: #d8d8d5;
					position: relative;

					.shape {
						opacity: 0;
						transform: translateY(6rpx);
						position: absolute;
						bottom: -6rpx;
						width: 100%;
						height: 8rpx;
						background-color: #1534ce;
						border-radius: 8rpx;
						transition: 0.3s ease;
					}
				}

				.item__active {
					color: #3b3c40;

					.shape {
						opacity: 1;
						transform: translateY(0rpx);
					}
				}
			}
		}
	}
	
	.imgs {
		padding-top: 10rpx;
		width: 100%;
		@include clear();

		.img {
			float: left;
			margin-right: 25rpx;
			width: 113rpx;
			height: 42rpx;
			background-color: #ffffff;
			border-radius: 21rpx;
			border: 1rpx solid #1534ce;
			text-align: center;
			line-height: 42rpx;
			font-size: 16rpx;
			font-weight: bold;
			font-stretch: normal;
			line-height: 42rpx;
			letter-spacing: 0rpx;
			color: #1534ce;
			box-shadow: 0 0 30rpx 8rpx rgba(#bcbcb5, 0.17);

			&:last-child {
				margin-right: 0;
			}
		}

		.img_disabled {
			color: rgba(#999, 0.3);
		}

	}
</style>
